package com.tjsinfo.tjsoa.workplan.action;

import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.system.bo.ISystemUserBo;
import com.tjsinfo.tjsoa.system.vo.TSystemUser;
import com.tjsinfo.tjsoa.system.vo.User;
import com.tjsinfo.tjsoa.workplan.bo.IWorkPlanMainBo;
import com.tjsinfo.tjsoa.workplan.vo.WorkPlanMain;

public class CheckDefalntWorkPlanDateModleAction extends WorkPlanDateModleAction{
private IWorkPlanMainBo workPlanMainBo;
private ISystemUserBo systemUserBo;

	
	public ISystemUserBo getSystemUserBo() {
	return systemUserBo;
}

public void setSystemUserBo(ISystemUserBo systemUserBo) {
	this.systemUserBo = systemUserBo;
}

/* (non-Javadoc)
 * @see com.tjsinfo.tjsoa.workplan.action.WorkPlanDateModleAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response)
		throws Exception {
	// TODO Auto-generated method stub
	Date date = new Date();
	User user = new User();
	user.setUser_id(Integer.parseInt(request.getParameter("id")));
	TSystemUser systemUser = systemUserBo.findByIdSystemUser(Integer.parseInt(request.getParameter("id")));
	request.setAttribute("systemUser", systemUser);
	request.setAttribute("userinfoid", Integer.parseInt(request.getParameter("id")));
	Map<Date, WorkPlanMain> workplanmap = getMap(date, user,"D", 1);
	request.setAttribute("workplanmap", workplanmap);
	request.setAttribute("yueli", date);
	return findforward(mapping);
}

	/**
	 * @return the workPlanMainBo
	 */
	public IWorkPlanMainBo getWorkPlanMainBo() {
		return workPlanMainBo;
	}

	/**
	 * @param workPlanMainBo the workPlanMainBo to set
	 */
	public void setWorkPlanMainBo(IWorkPlanMainBo workPlanMainBo) {
		this.workPlanMainBo = workPlanMainBo;
	}
	protected Map<Date, WorkPlanMain> getMap(Date date, User user,String type,Integer start) {
		Map<Date, WorkPlanMain> workplanmap =   workPlanMainBo.checkDefinntWorkPlan(type, date.getYear() +1900, user.getUser_id(), start);
		return workplanmap;
	}
}
